<?php
	vendor("taobao.Util");
	class TestAction extends Action{
		protected $_method = 'taobao.shop.get';
		
		/**
		 * 获得店铺信息
		 * @return unknown_type
		 */
		public function index(){
			
			//API系统参数
			$paramArr = array(
				'api_key' => APP_KEY,
				'method' => 'taobao.shop.get',
				'format' => 'xml',
				'v' => '1.0',
				'timestamp' => date('Y-m-d H:i:s'),
				'fields' => 'sid,cid,nick,title,desc,bulletin,pic_path,created,modified',
				'nick' => 'alipublic01',
			);
			
			$result = Util::getResult($paramArr);
			$result = Util::getXmlData($result);
			
			dump($result['shop']);
			
			$this->assign('info',$result['shop']);
			$this->display();
		}
		
		public function type(){
			
			//API系统参数
			$paramArr = array(
				'api_key' => APP_KEY,
				'method' => 'taobao.sellercats.list.get',
				'format' => 'xml',
				'v' => '1.0',
				'timestamp' => date('Y-m-d H:i:s'),
//				'fields' => 'sid,cid,nick,title,desc,bulletin,pic_path,created,modified',
				'nick' => 'alipublic01',
//				'nick' => 'alipublic05',
			);
			
			$result = Util::getResult($paramArr);
			$result = Util::getXmlData($result);
			
			dump($result['seller_cat']);
			
//			$this->assign('info',$result['shop']);
//			$this->display();
		}
		
		/**
		 * 根据类别查找商品
		 * @return unknown_type
		 */
		public function products(){
			
			//API系统参数
			$paramArr = array(
				'api_key' => APP_KEY,
				'method' => 'taobao.itemcats.get.v2',
				'format' => 'xml',
				'v' => '1.0',
				'timestamp' => date('Y-m-d H:i:s'),
				'fields' => 'cid,parent_cid,name,is_parent,status,sort_order',
				'nicks' => 'alipublic01',
				'parent_cid' => '0',
			);
			
			$result = Util::getResult($paramArr);
			$result = Util::getXmlData($result);

			print_r($paramArr);
			
			dump($result);
			
//			$this->assign('info',$result['shop']);
//			$this->display();
		}
		
		//获取当前会话用户出售中的商品列表
		public function items(){
			
			//API系统参数
			$paramArr = array(
				'api_key' => Util::getAppKey(),
				'method' => 'taobao.items.onsale.get',
				'format' => 'xml',
				'v' => '1.0',
				'timestamp' => date('Y-m-d H:i:s'),
				'fields' => 'approve_status,iid,num_iid,title,nick,type,cid,pic_path,num,props,valid_thru,list_time,price,has_discount,has_invoice,has_warranty,has_showcase,modified,delist_time,postage_id,seller_cids,outer_id',
				'session' => '10771987bef823523e03cf3f9249e88c1',
			);
			
			$result = Util::getResult($paramArr);
			$result = Util::getXmlData($result);

			dump($result);
			
//			$this->assign('info',$result['shop']);
//			$this->display();
		}
		
		
	}
?>